package com.aysf.drafter.controller;

import com.aysf.drafter.entity.Admin;
import com.aysf.drafter.entity.Result;
import com.aysf.drafter.service.IAdminService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author MaoZz
 * @since 2024-12-26 18:05:17
 */
@RestController
@CrossOrigin
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private IAdminService adminService;


    @RequestMapping("/login")
    public Result login(@RequestBody Admin admin) {
        Admin one = adminService.getOne(new QueryWrapper<Admin>()
                .eq("name", admin.getName())
                .eq("password", admin.getPassword()));
        if (one != null) {
            return new Result("success", one);
        } else return new Result("error");
    }

}
